package com.dux.example.easyyapi.controller;

import com.dux.example.easyyapi.dto.Result;
import com.dux.example.easyyapi.dto.Student;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.validation.Valid;

/**
 * 学生业务
 * @author dux
 * @date 2023/5/24
 */
@Api(tags="学生业务")
@RestController
public class StudentController {

    /**
     * 查询学生信息
     * 这是接口备注：首行注释为“接口名字”，后面的注释为“接口备注”
     * @return
     */
    @RequestMapping(value = "/student/getStudent", method = RequestMethod.POST)
    public Result<Student> getStudent(@RequestBody Student params) {
        return new Result<>();
    }

    // 也可以使用swagger的注解@ApiOperation声明接口名字
    @ApiOperation(value = "删除学生信息")
    @RequestMapping(value = "/student/deleteStudent", method = RequestMethod.POST)
    public Result deleteStudent(@RequestBody Student params) {
        return new Result();
    }

    /**
     * 修改学生信息
     * 这是接口备注：类字段上有javax.validation注解、EasyYapi规定的关键字“@required”时，生成的接口字段为“必须”字段
     * @return
     */
    @RequestMapping(value = "/student/updateStudent", method = RequestMethod.POST)
    public Result updateStudent(@RequestBody @Valid Student params) {
        return new Result();
    }

}
